import { createStore, applyMiddleware } from 'redux'
import thunk from 'redux-thunk'
import { persistStore, persistReducer } from 'redux-persist'
//import storage from 'redux-persist/lib/storage' // defaults to localStorage for web and AsyncStorage for react-native

import historyNav from './historyNav.js'

import autoMergeLevel2 from 'redux-persist/lib/stateReconciler/autoMergeLevel2';
import storageSession from 'redux-persist/lib/storage/session'
import hardSet from 'redux-persist/lib/stateReconciler/hardSet'

const persistConfig = {
    key: 'root',
    storage: storageSession,
    blacklist: [],//里不持久化的数据
    // whitelist: ['navigation'] // navigation会存入缓存，其他不会存，适用于大多数数据并不会实时从后台拿数据

    stateReconciler: autoMergeLevel2 // 查看 'Merge Process' 部分的具体情况
}

const persistedReducer = persistReducer(persistConfig, historyNav)
const store = createStore(persistedReducer, applyMiddleware(thunk))
export const persistor = persistStore(store)
export default store